package com.okq.action.base;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;

/**
 * 描述 : 基础action支持类
 * 作者 : zdl
 * 日期 : 2017/3/15 11:50
 */
@SuppressWarnings("all")
public class BaseActionSupport extends ActionSupport {

	private static final long serialVersionUID = 8214401597238561460L;

	private String message;

	public BaseActionSupport() {
	}

	public String getMessage() {
		return this.message;
	}

	public void setMessage(String var1) {
		this.message = var1;
	}

	protected String add() {
		return "success";
	}

	protected String edit() {
		return "success";
	}

	protected String delete() {
		return "success";
	}

	protected String query() throws Exception {
		return "success";
	}

	protected HttpSession getSession() {
		return this.getRequest().getSession();
	}

	protected HttpServletRequest getRequest() {
		return ServletActionContext.getRequest();
	}

	protected HttpServletResponse getResponse() {
		HttpServletResponse var1 = ServletActionContext.getResponse();
		var1.setContentType("text/html;charset=UTF-8");
		var1.setCharacterEncoding("UTF-8");
		return var1;
	}

	protected PrintWriter getWriter() throws IOException {
		this.getResponse().reset();
		return this.getResponse().getWriter();
	}

	protected PrintStream getPrintStream() throws IOException {
		this.getResponse().reset();
		return new PrintStream(this.getResponse().getOutputStream());
	}

	protected void ajax(String var1) throws Exception {
		PrintWriter var2 = null;
		try {
			var2 = this.getResponse().getWriter();
			var2.print(var1);
			var2.flush();
		} catch (Exception var7) {
			throw var7;
		} finally {
			if (var2 != null) {
				var2.close();
			}
		}
	}

	protected String getRequestURI() {
		return this.getRequest().getRequestURI();
	}

}
